﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.ApplicationModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace MultiApp.UserControls
{
    public sealed partial class TranslationControl : UserControl
    {

        List<string> languageName = new List<string>();
        List<string> languageShort = new List<string>();

        public TranslationControl()
        {
            this.InitializeComponent();
            populateCombo();
        }

        public async void populateCombo()
        {
            var doc = await Package.Current.InstalledLocation.GetFileAsync("Data\\translate.txt");
            var languages = await Windows.Storage.FileIO.ReadLinesAsync(doc);


            foreach (string s in languages)
            {
                int i = 0;
                string[] lang = s.Split('(',')');
                languageName.Add(lang[i]);
                i++;
                languageShort.Add(lang[i]);
            }

            cmbFrom.ItemsSource = languageName;
            cmbTo.ItemsSource = languageShort;
        }


        public void translate()
        {
            string langFrom = languageShort.ElementAt(cmbFrom.SelectedIndex);
            string langto = languageShort.ElementAt(cmbTo.SelectedIndex);
            

        }
        
    }
}
